#include "CPlayer.h"
#include "../TinyXml/tinyxml.h"


CPlayer::CPlayer()
{
	m_nType = OBJ_PLAYER;
	m_nClassType = SHORT_RANGE;
}
CPlayer::~CPlayer()
{
}


bool CPlayer::CheckCollision( IBaseInterface* pBase )
{
	return false;
}
RECT CPlayer::GetCollisionRect()
{
	RECT fake = {0,0,0,0};
	return fake;
}

void CPlayer::HandleEvent(CEvent* pEvent)
{
}

//void CPlayer::Update(float _fDT)
//{
//}
//
//void CPlayer::Render()
//{
//
//}

bool CPlayer::Load(const char* szFileName, char _input)
{
	TiXmlDocument doc;

	if(doc.LoadFile(szFileName) == false)
		return false;

	TiXmlElement* pRoot =doc.RootElement();

	if(!pRoot)
		return false;

	TiXmlElement* pFilePath = pRoot->FirstChildElement("FilePath");

	if(pFilePath)
	{
		// ascii variables
		if(_input == 113)
			m_nImagePath = pFilePath->Attribute("Short");
		else if(_input == 119)
			m_nImagePath = pFilePath->Attribute("Medium");
		else if (_input == 101)
			m_nImagePath = pFilePath->Attribute("Long");
	}


	return true;
}

bool CPlayer::Save(const char* xmlFileName,const char* xmlFileName1,const char* xmlFileName2,const char* xmlFileName3)
{
	TiXmlDocument doc;
	TiXmlDeclaration* pDec = new TiXmlDeclaration("1.0","utf-8","");
	doc.LinkEndChild(pDec);
	TiXmlElement* pRoot = new TiXmlElement("ImageFilePaths");
	doc.LinkEndChild(pRoot);

	TiXmlElement* pfPath = new TiXmlElement("FilePath");
	pfPath->SetAttribute("Short",xmlFileName1);
	pfPath->SetAttribute("Medium",xmlFileName2);
	pfPath->SetAttribute("Long",xmlFileName3);

	pRoot->LinkEndChild(pfPath);

	if(doc.SaveFile(xmlFileName) == false)
		return false;

	return true;

}
